package org.zpmis.domain.customer.vo;

import lombok.Data;
import org.zpmis.domain.customer.model.CustomerPlan;
import org.zpmis.domain.customer.model.ReturnVisit;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
public class IntentionTrackVo {

    /**
     * 企业名称
     */
    private String companyName;
    /**
     * 联系人
     */
    private String contactPerson;
    /**
     * 联系电话
     */
    private String contactMobile;
    /**
     * 跟进人/创建人
     */
    private String chargePerson;
    /**
     * 回访方式
     */
    private Integer visitType;
    /**
     * 回访结果
     */
    private Integer visitResult;
    /**
     * 回访时间/计划时间
     */
    private Long visitTime;

    /**
     * 回访时间/计划时间
     */
    private String visitTimeStr;

    /**
     * 结果描述/计划描述
     */
    private String resultDesc;
    /**
     * 数据类型 1 回访 2 计划
     */
    private Integer type;


    public IntentionTrackVo(ReturnVisit returnVisit) {
        this.companyName = returnVisit.getCompanyName();
        this.contactPerson = returnVisit.getContactPerson();
        this.contactMobile = returnVisit.getContactMobile();
        this.chargePerson = returnVisit.getChargePerson();
        this.visitType = returnVisit.getVisitType();
        this.visitResult = returnVisit.getVisitResult();
        this.visitTime = returnVisit.getVisitTime();
        this.resultDesc = returnVisit.getResultDesc();
        this.visitTimeStr = returnVisit.getVisitTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(returnVisit.getVisitTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.type = 1;
    }

    public IntentionTrackVo(CustomerPlan customerPlan) {
        this.companyName = customerPlan.getCompanyName();
        this.contactPerson = customerPlan.getContactPerson();
        this.contactMobile = customerPlan.getContactMobile();
        this.chargePerson = customerPlan.getChargePerson();
        this.visitType = customerPlan.getVisitType();
        this.visitTime = customerPlan.getVisitTime();
        this.resultDesc = customerPlan.getPlanDesc();
        this.visitTimeStr = customerPlan.getVisitTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerPlan.getVisitTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.type = 2;
    }
}
